/* $Header: zone_ui.h,v 2.2 01/10/02 10:30:48 przybyls Exp $ */

/***********************************************************************/
/* INCLUDE FILE NAME:  zone_ui.h                                       */
/* ==================                                                  */
/*                                                                     */
/* Author:  Lesley Freed                                               */
/*                                                                     */
/* COMMENT:  Defines function prototypes used by the user interface    */
/*           for thermal zone user interface.                          */
/*                                                                     */
/***********************************************************************/

#ifndef Z_UI_H
#define Z_UI_H

/*****************************/
/*   IFDEFS                  */
/*****************************/


/*****************************/
/*   SYMBOLIC CONSTANTS      */
/*****************************/

#define pOVEN_TEMP              &Oven_Table
#define pFRONT_DET_TEMP         &Deta_Table
#define pBACK_DET_TEMP          &Detb_Table
#define pFRONT_INLET_TEMP       &Inja_Table
#define pBACK_INLET_TEMP        &Injb_Table
#define pAUX_1_TEMP             &Auxa_Table
#define pAUX_2_TEMP             &Auxb_Table

#define TEMP_SIG_OFFSET         TEMP_OFFSET*64*256

/* reserved value: OFF run table setpt */
#define RTT_TEMP_OFF_VALUE      -1000

/*****************************/
/*   MACROS                  */
/*****************************/


/*****************************/
/*   TYPEDEFS                */
/*****************************/

typedef enum
{
   ZONE_OK          = 0,
   THERMAL_SHUTDOWN = 1,
   SHUTDOWN_BY_FLOW = 2,
   SHUTDOWN_BY_CRYO = 3

} ZONE_ERR;


/*****************************/
/*   FUNCTION PROTOTYPES     */
/*****************************/

/* zone_cmd.c functions */

TEMP_DISPLAY    TempToDegrees( TEMP_ACTUAL temp );
INT32           TempToDegreesScaled( TEMP_ACTUAL temp, U_INT8 scale );
TEMP_DISPLAY    TempSetptToDegrees( TEMP_ACTUAL temp );
TEMP_SETPT      DegreesToTemp( TEMP_DISPLAY temp );
void            DisplayPIDState( void );
TIME_SETPT      TimeToMilliSecs( TIME_SETPT time);
TIME_SETPT      MilliSecsToTime( TIME_SETPT msecs);
RATE_SETPT      OvenRateToIU( RATE_SETPT rate);
RATE_SETPT      IUToOvenRate( RATE_SETPT rate);
U_INT32         CminToEvalCounts( U_INT32 time );

/* zone_ui.c functions */

INT32   GetTempActual( pZONE_TABLE zone );
INT32   GetTempSetpt( pZONE_TABLE zone );
INT32   GetTempActualScaled( pZONE_TABLE zone, U_INT8 scale );
INT32   GetTempSetptScaled( pZONE_TABLE zone, U_INT8 scale );
INT32   GetInitTempSetpt( pZONE_TABLE zone );
INT32   GetInitTimeSetpt( pZONE_TABLE zone );
INT32   GetRateSetpt( pZONE_TABLE, U_INT8 rampnum);
INT32   GetFinalTempSetpt( pZONE_TABLE, U_INT8 rampnum);
INT32   GetFinalTimeSetpt( pZONE_TABLE, U_INT8 rampnum);
INT32   GetPostTimeSetpt (void);
INT32   GetPostTempSetpt (void);
ON_OFF  GetOvenTrackModeOnOff( pZONE_TABLE zone );
BIT8    GetZoneType( pZONE_TABLE zone );
ZONE_TYPE GetZoneLocation( pZONE_TABLE zone );
pZONE_TABLE GetZonePtr( ZONE_TYPE type );
pZONE_TABLE InletZonePtr( POSITION type );

AUX_TYPE GetAuxType( U_INT16 aux_no );

UI_ERR   CheckTempSetpt( pZONE_TABLE zone, INT32 setpt );
UI_ERR   CheckTimeSetpt( INT32 setpt );

UI_ERR   SetTempSetpt( pZONE_TABLE zone, INT32 setpt );
UI_ERR   SetInitTempSetpt( pZONE_TABLE zone, INT32 setpt );
UI_ERR   SetInitTimeSetpt( pZONE_TABLE zone, INT32 setpt );
UI_ERR   SetFinalTempSetpt( pZONE_TABLE zone, INT32 setpt, U_INT8 rampnum );
UI_ERR   SetFinalTimeSetpt( pZONE_TABLE zone, INT32 setpt, U_INT8 rampnum );
UI_ERR   SetRateSetpt( pZONE_TABLE zone, INT32 setpt, U_INT8 rampnum );
UI_ERR   SetPostTimeSetpt (INT32 setpt);
UI_ERR   DcSetPostTimeSetpt (INT32 setpt);
UI_ERR   SetPostTempSetpt (INT32 setpt);
UI_ERR   SetOvenTrackModeOnOff( pZONE_TABLE zone, ON_OFF setpt );

ZONE_ERR      GetTempStatus( pZONE_TABLE zone );
ON_OFF        GetTempOnOff( pZONE_TABLE zone );
ON_OFF        GetTempOnOffSetpt( pZONE_TABLE zone );
ZONE_PRESENCE GetTempZonePresence( pZONE_TABLE zone );
BIT8          GetZonePresence( pZONE_TABLE zone );
BIT8          GetZonesOverWattage( pZONE_TABLE pzone );

UI_ERR   SetTempOn ( pZONE_TABLE zone );
UI_ERR   SetTempOff ( pZONE_TABLE zone );

UI_ERR   SetAuxType ( U_INT16 aux_no, AUX_TYPE type );

void     TurnOvenOff( void );
void     RequestOvenShutOffByColumn( void );
void     ClearOvenShutOffByColumn( void );

UI_ERR   SetOvenHoldOff( ON_OFF on_off );

OVEN_STATUS GetOvenStatus (void);
BIT8     ClearableOvenShutdown( void );
BIT8     OvenDoorOpen( void );
BIT8     SmallZoneIsShutdown( pZONE_TABLE pzone );

INT32    GetZoneMinSetpt( pZONE_TABLE zone );
INT32    GetZoneMaxSetpt( pZONE_TABLE zone );
INT32    GetZoneMaxRate( pZONE_TABLE zone );

/* oven_ui.c functions */

UI_ERR  CheckOvenMax( INT32 setpt );
UI_ERR  CheckCryoOnOffSetpt( pZONE_TABLE pzone, ON_OFF on_off );
UI_ERR  CheckCryoTimeout( INT32 time );
UI_ERR  CheckOvenCalib( INT32 calib );
UI_ERR  CheckCryoType( pZONE_TABLE pzone, CRYO_TYPE cryo_type );
BIT8    CryoOnly( pZONE_TABLE pzone );

UI_ERR  SetOvenMax( INT32 setpt );
UI_ERR  SetOvenEquibTime( INT32 setpt );
UI_ERR  SetCryoOnOff( pZONE_TABLE pzone, ON_OFF on_off );
UI_ERR  SetCryoBlastOnOff( pZONE_TABLE pzone, ON_OFF on_off );
UI_ERR  SetCryoTimeoutOnOff( pZONE_TABLE pzone, ON_OFF on_off );
UI_ERR  SetCryoTimeoutOnOff( pZONE_TABLE pzone, ON_OFF on_off );
UI_ERR  SetCryoTimeout( pZONE_TABLE pzone, INT32 time );
UI_ERR  DCSetCryoTimeout( pZONE_TABLE pzone, INT32 time );
UI_ERR  SetCryoShutdownOnOff( pZONE_TABLE pzone, ON_OFF on_off );
UI_ERR  SetCryoAmbientTemp( pZONE_TABLE pzone, INT32 temp );
UI_ERR  SetOvenTempMeasured (INT32 temp);
UI_ERR  SetOvenCalib (INT32 calib);
UI_ERR  DeleteOvenCalib (void);
UI_ERR  SetCryoType ( pZONE_TABLE pzone, CRYO_TYPE cryo_type );

INT32     GetOvenMax( void );
INT32     GetOvenEquibTime( void );
ON_OFF    GetCryoOnOff( pZONE_TABLE pzone );
ON_OFF    GetCryoBlastOnOff( pZONE_TABLE pzone );
BIT8      GetCryoPresence( pZONE_TABLE pzone );
CRYO_TYPE GetCryoType ( pZONE_TABLE pzone );
ON_OFF    GetCryoTimeoutOnOff( pZONE_TABLE pzone );
INT32     GetCryoTimeout( pZONE_TABLE pzone );
INT32     DCGetCryoTimeout( pZONE_TABLE pzone );
ON_OFF    GetCryoShutdownOnOff( pZONE_TABLE pzone );
INT32     GetCryoAmbientTemp( pZONE_TABLE pzone );
INT32     GetOvenTempMeasured (void);
INT32     GetOvenCalib (void);
DATETIME  GetOvenCalibDate (void);
INT32     GetLowerZoneLimit (pZONE_TABLE zone);
INT32     GetUpperZoneLimit (pZONE_TABLE zone);
INT32     GetMinUseCryoTemp( pZONE_TABLE pzone );
INT32     GetMaxUseCryoTemp( pZONE_TABLE pzone );

   /* Test functions */
INT32   GetCryoFaultTimer( pZONE_TABLE pzone );
INT32   GetCryoTimeoutTimer( pZONE_TABLE pzone );
INT32   GetCryoAccum( pZONE_TABLE pzone );
INT32   GetFlapSetpt( void );
INT32   GetFlapActual( void );

   /* mux_diag.c functions */

UI_ERR  SetGenericMuxAdcAddr( INT32 addr );
UI_ERR  SetPreChannelAddr( INT32 addr );
UI_ERR  SetPreChannelOnOff( ON_OFF on_off );

INT32   GetMuxAdcAddr( void );
INT32   GetGenericMuxAdcAddr( void );
INT32   GetPreChannelAddr( void );
ON_OFF  GetPreChannelOnOff( void );

/* zone_diag.c functions */
INT16   GetZoneDutyCycle( pZONE_TABLE pzone );
INT16   GetFilteredTuneZoneDutyCycle( void );
U_INT8  GetConstDutyCycle( pZONE_TABLE pzone );
UI_ERR  SetConstDutyCycle( pZONE_TABLE pzone, INT32 duty_cycle );
ON_OFF  GetConstDutyCycleOnOff( pZONE_TABLE pzone );
UI_ERR  SetConstDutyCycleOnOff(pZONE_TABLE pzone,ON_OFF on_off);
U_INT8  GetCryoConstDutyCycle( pZONE_TABLE pzone );
UI_ERR  SetCryoConstDutyCycle( pZONE_TABLE pzone,INT32 demand );
ON_OFF  GetCryoConstDutyCycleOnOff( pZONE_TABLE pzone );
UI_ERR  SetCryoConstDutyCycleOnOff( pZONE_TABLE pzone,ON_OFF on_off );
INT32   GetCryoOnCount( pZONE_TABLE pzone);
U_INT8  GetCryoDutyCycle( pZONE_TABLE pzone);
void    TurnConstDutyCycleOn( pZONE_TABLE pzone );
void    TurnConstDutyCycleOff( pZONE_TABLE pzone );
void    TurnCryoConstDutyCycleOn( pZONE_TABLE pzone);
void    TurnCryoConstDutyCycleOff( pZONE_TABLE pzone);
U_INT32    GetIgnoreNotReadyTimer( pZONE_TABLE pzone );
ZONE_READY GetZoneReadyEvalState( pZONE_TABLE pzone );

U_INT16  GetCryoMaxOnCount( pZONE_TABLE pzone );
UI_ERR  SetCryoMaxOnCount( pZONE_TABLE pzone, U_INT16 on_count );

U_INT16  GetCryoPeriod( pZONE_TABLE pzone );
UI_ERR  SetCryoPeriod( pZONE_TABLE pzone, U_INT16 period );
U_INT16  GetCryoBangPeriod( pZONE_TABLE pzone );
UI_ERR  SetCryoBangPeriod( pZONE_TABLE pzone, U_INT16 period );

/* zone_tune.c functions */

/* PID control */
INT32       GetPropGain( pZONE_TABLE pzone );
INT32       GetIntegGain( pZONE_TABLE pzone );
INT32       GetDerivGain( pZONE_TABLE pzone );

UI_ERR      SetPropGain( pZONE_TABLE pzone, INT32 gain );
UI_ERR      SetIntegGain( pZONE_TABLE pzone, INT32 gain );
UI_ERR      SetDerivGain( pZONE_TABLE pzone, INT32 gain );

UI_ERR      CalculateZonePIDs( pZONE_TABLE pzone );

UI_ERR      SetZoneMinIntegClamp( pZONE_TABLE pzone, INTEG_CLAMP type );
INTEG_CLAMP GetZoneMinIntegClamp( pZONE_TABLE pzone );
UI_ERR      SetZoneMaxIntegClamp( pZONE_TABLE pzone, INTEG_CLAMP type );
INTEG_CLAMP GetZoneMaxIntegClamp( pZONE_TABLE pzone );
INT32       GetZoneMinIntegAccum( pZONE_TABLE pzone );
INT32       GetZoneMaxIntegAccum( pZONE_TABLE pzone );
TEMP_SENSOR GetZoneSensorType( pZONE_TABLE pzone );
UI_ERR      SetZoneSensorType( pZONE_TABLE pzone, TEMP_SENSOR sensor_type );
INT32       GetZoneControlFreq( pZONE_TABLE pzone );
UI_ERR      SetZoneControlFreq( pZONE_TABLE pzone, INT32 freq );
INT32       GetZoneCryoControlType( pZONE_TABLE pzone );
UI_ERR      SetZoneCryoControlType( pZONE_TABLE pzone, INT32 type );

INT32       GetZonePropDivisor( pZONE_TABLE pzone );
INT32       GetZoneIntegDivisor( pZONE_TABLE pzone );
INT32       GetZoneDerivDivisor( pZONE_TABLE pzone );
UI_ERR      SetZonePropDivisor( pZONE_TABLE pzone, INT32 divisor );
UI_ERR      SetZoneIntegDivisor( pZONE_TABLE pzone, INT32 divisor );
UI_ERR      SetZoneDerivDivisor( pZONE_TABLE pzone, INT32 divisor );
INT32       GetZoneMinControlTemp( pZONE_TABLE pzone );
INT32       GetZoneMaxControlTemp( pZONE_TABLE pzone );
UI_ERR      SetZoneMinControlTemp( pZONE_TABLE pzone, INT32 temp );
UI_ERR      SetZoneMaxControlTemp( pZONE_TABLE pzone, INT32 temp );

/* PID tuning */
ON_OFF      GetZoneTuneOnOff( pZONE_TABLE pzone );
INT32       GetTunePropGain(pZONE_TABLE pzone );
INT32       GetTuneTimePeriod( pZONE_TABLE pzone );
UI_ERR      SetZoneTuneOnOff( pZONE_TABLE pzone, ON_OFF on_off );
UI_ERR      SetTunePropGain(pZONE_TABLE pzone, INT32 gain);
UI_ERR      SetTuneTimePeriod( pZONE_TABLE pzone, INT32 time );

/* ramp comp */
INT32      GetZoneRampCompType( pZONE_TABLE pzone );
INT32      GetZoneRampMult( pZONE_TABLE pzone );
INT32      GetZoneRampDiv( pZONE_TABLE pzone );
INT32      GetZoneRampDelay( pZONE_TABLE pzone );
UI_ERR     SetDCZoneRampCompType( pZONE_TABLE pzone, INT32 value );
UI_ERR     SetZoneRampMult( pZONE_TABLE pzone, INT32 value );
UI_ERR     SetZoneRampDiv( pZONE_TABLE pzone, INT32 value );
UI_ERR     SetZoneRampDelay( pZONE_TABLE pzone, INT32 value );

/* temperature limits */
UI_ERR     SetZoneMinSetpt( pZONE_TABLE pzone, INT32 min_setpt );
UI_ERR     SetZoneMaxSetpt( pZONE_TABLE pzone, INT32 max_setpt );
UI_ERR     SetZoneMaxRate( pZONE_TABLE pzone, INT32 max_rate );

BIT8       GetZoneUserLimitsChanged( pZONE_TABLE pzone );

/* zone_pwr.c functions */
WATTAGE GetZoneWattageRange( ZONE_TYPE zone );

/* zone_config.c functions */
void      SetZoneType( pZONE_TABLE pzone, BIT8 type );

/* zone_time.c functions */
void      RTTSetAux1Temp( INT32 temp );
void      RTTSetAux2Temp( INT32 temp );
void      ResetAuxTemperatures( void );

/* zone_cryo.c functions */
INT32     GetCryoBlastOffError( pZONE_TABLE pzone );
UI_ERR    SetCryoBlastOffError( pZONE_TABLE pzone, INT32 error );
INT32     GetCryoBlastOnError( pZONE_TABLE pzone );
UI_ERR    SetCryoBlastOnError( pZONE_TABLE pzone, INT32 error );

#pragma SECTION PROG=prog
UI_ERR    SetOvenType( OVEN_TYPE oven_type );
OVEN_TYPE GetOvenType( void );
#pragma SECTION UNDO

/* zone_meth.c functions */
void    CheckZoneConfigInWkfile( void );
UI_ERR  TakeThisOvenMaxAndShoveIt( INT32 setpt );

#endif
